﻿using System;
using System.Data;
using System.Collections.Generic;
using Chenxin.Lib.Business.Entity;
namespace Chenxin.Lib.Business.BLL
{
    /// <summary>
    /// 业务逻辑类ApplyPointAllot 的摘要说明。
    /// </summary>
    public class ApplyPointAllot
    {
        public ApplyPointAllot()
        { }
        #region  成员方法
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public static void Add(Chenxin.Lib.Business.Entity.ApplyPointAllot model)
        {
            Chenxin.Lib.Business.DAL.ApplyPointAllot.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public static void Update(Chenxin.Lib.Business.Entity.ApplyPointAllot model)
        {
            Chenxin.Lib.Business.DAL.ApplyPointAllot.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public static void Delete(Guid RecordId)
        {

            Chenxin.Lib.Business.DAL.ApplyPointAllot.Delete(RecordId);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public static void DeleteByContractId(Guid ContractId)
        {

            Chenxin.Lib.Business.DAL.ApplyPointAllot.DeleteByContractId(ContractId);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public static  Chenxin.Lib.Business.Entity.ApplyPointAllot GetModel(Guid RecordId)
        {

            return Chenxin.Lib.Business.DAL.ApplyPointAllot.GetModel(RecordId);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public static List<Chenxin.Lib.Business.Entity.ApplyPointAllot> GetModelByContractId(string ContractId)
        {
            string strWhere = string.Format( "ContractId = '{0}'",ContractId);
            return GetModelList(strWhere);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public static DataSet GetList(string strWhere)
        {
            return Chenxin.Lib.Business.DAL.ApplyPointAllot.GetList(strWhere);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public static List<Chenxin.Lib.Business.Entity.ApplyPointAllot> GetModelList(string strWhere)
        {
            DataSet ds = Chenxin.Lib.Business.DAL.ApplyPointAllot.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public static List<Chenxin.Lib.Business.Entity.ApplyPointAllot> DataTableToList(DataTable dt)
        {
            List<Chenxin.Lib.Business.Entity.ApplyPointAllot> modelList = new List<Chenxin.Lib.Business.Entity.ApplyPointAllot>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Chenxin.Lib.Business.Entity.ApplyPointAllot model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Chenxin.Lib.Business.Entity.ApplyPointAllot();
                    if (dt.Rows[n]["RecordId"].ToString() != "")
                    {
                        model.RecordId = new Guid(dt.Rows[n]["RecordId"].ToString());
                    }
                    if (dt.Rows[n]["ContractId"].ToString() != "")
                    {
                        model.ContractId = new Guid(dt.Rows[n]["ContractId"].ToString());
                    }
                    model.BuyerOrVenderInfo = dt.Rows[n]["BuyerOrVenderInfo"].ToString();
                    if (dt.Rows[n]["Point"].ToString() != "")
                    {
                        model.Point = decimal.Parse(dt.Rows[n]["Point"].ToString());
                    }
                    model.MajordomoName = dt.Rows[n]["MajordomoName"].ToString();
                    if (dt.Rows[n]["MajordomoId"].ToString() != "")
                    {
                        model.MajordomoId = new Guid(dt.Rows[n]["MajordomoId"].ToString());
                    }
                    model.RegionManagerName = dt.Rows[n]["RegionManagerName"].ToString();
                    if (dt.Rows[n]["RegionManagerId"].ToString() != "")
                    {
                        model.RegionManagerId = new Guid(dt.Rows[n]["RegionManagerId"].ToString());
                    }
                    model.MangerName = dt.Rows[n]["MangerName"].ToString();
                    if (dt.Rows[n]["MangerId"].ToString() != "")
                    {
                        model.MangerId = new Guid(dt.Rows[n]["MangerId"].ToString());
                    }
                    if (dt.Rows[n]["DeparterManagerId"].ToString() != "")
                    {
                        model.DeparterManagerId = new Guid(dt.Rows[n]["DeparterManagerId"].ToString());
                    }
                    model.DeparterManagerName = dt.Rows[n]["DeparterManagerName"].ToString();
                    model.Employee = dt.Rows[n]["Employee"].ToString();
                    if (dt.Rows[n]["EmployeeId"].ToString() != "")
                    {
                        model.EmployeeId = new Guid(dt.Rows[n]["EmployeeId"].ToString());
                    }
                    model.Depart = dt.Rows[n]["Depart"].ToString();
                    if (dt.Rows[n]["DepartId"].ToString() != "")
                    {
                        model.DepartId = new Guid(dt.Rows[n]["DepartId"].ToString());
                    }
                    if (dt.Rows[n]["CreateTime"].ToString() != "")
                    {
                        model.CreateTime = DateTime.Parse(dt.Rows[n]["CreateTime"].ToString());
                    }
                    if (dt.Rows[n]["UpdateTime"].ToString() != "")
                    {
                        model.UpdateTime = DateTime.Parse(dt.Rows[n]["UpdateTime"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public static List<Chenxin.Lib.Business.Entity.ApplyPointAllot> GetListArray(Guid id)
        {
            return Chenxin.Lib.Business.DAL.ApplyPointAllot.GetListArray(string.Format(" ContractId = '{0}'", id));
        }
       
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public static DataSet GetAllList()
        {
            return GetList("");
        }

        #endregion  成员方法
    }
}

